<style>
#app{display: table;width:100%;}
body{background: #fff;}
.ccdeal .usercener_all{
    display: flex;
    justify-content: space-between;
	margin-top:20px;
	min-width: 353px;

}	
.ccdeal .usercenter_all .el-tabs{margin:0 0 20px 0;width: 100%;}
.ccdeal .usercenter_cc{
	border:1px solid #dcdcdc;
	width: 49.5%;
	height:353px;
}
.ccdeal .list_form{    width: 500px;
    /*height: 290px;*/
    margin: 0 auto;
    margin-top: 20px;
    border: 1px solid #f5f5f5;
    background: #f5f5f5;
    color: #333;margin-bottom:30px;
    padding-top: 15px;
    box-sizing: border-box;
}
.ccdeal .list_form .el-input__inner{height:36px;}
.ccdeal .list_form .el-form-item__label{line-height: 30px;}
.ccdeal .list_form .el-form-item{padding:0 35px;margin-bottom: 10px;}
.ccdeal .list_text{margin-left:35px;margin-bottom: 20px;display: inline-block;font-size: 12px;}
.ccdeal .list_form .list_buynum{margin-top:20px;}
.ccdeal .span_btn{
    color: #446E9B;
    cursor: pointer;
}
.ccdeal .span_btn_all{    width: 450px;
    height: 40px;
    /*margin-top: 27px;*/
    /*margin-left: 35px;*/
    font-size:14px;
    color: #fff;
    font-size: 14px;
    background: #03c086;
    border-radius: 3px;}
.ccdeal .span_btn_red{background: #f45758;border:none;}
.ccdeal .span_btn_all:hover,.span_btn_all:focus{opacity: 0.9; background: #03c086;}
.ccdeal .span_btn_red:hover,.span_btn_red:focus{opacity: 0.9; background: #f45758;}
.ccdeal.login_content{    width: 1200px;margin:0 auto;
    /*height: 99.8vh;*/
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    /*align-items: center;*/

    /*justify-content: center;*/
}
.ccdeal .usercenter_header{
	border:1px solid #dcdcdc;
	display: flex;
	height:152px;
	align-items: center;
	margin-top: 20px;
}
.ccdeal .header_left,.header_right{display: flex;padding:0 50px;    width: 50%;align-items: center;}
.ccdeal .header_left{    border-right: 1px solid #dcdcdc;flex:4;}
.ccdeal .header_text{ height: 65px;       align-items: center;  display: flex;flex-direction: column;margin-left: 17px;}
/*.header_right .header_text{display: flex;flex-direction: column;padding:0;}*/
.ccdeal .header_text span{height:50%;align-items: center;display: flex;}
.ccdeal .header_img{font-size:20px;}
.ccdeal .header_right{justify-content: center;}
.ccdeal .header_btn{    width: 200px;
    height: 130px;
    border: 1px solid #dcdcdc;
    background: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    /*margin-top: 10px;*/
}
.ccdeal .header_btn p{margin-bottom:0;}
.ccdeal .width_fixed{width:170px;}
.ccdeal .el-input__inner{height:32px;}
.ccdeal .el-table td{padding:12px 0;}
.ccdeal .el-form--inline .el-form-item{margin-bottom: 0;}
.ccdeal .list_content{margin-bottom: 30px;}
.ccdeal .alt_item{border-top: 1px solid #dcdcdc;width: 100%;}
.ccdeal .alt_title{
	    font-size: 16px;
    color: #333;
    height: 40px;
    line-height: 40px;
}
.ccdeal .alt_content_title{    font-size: 14px;
    color: #333;
    height: 40px;
    line-height: 40px;
}
.ccdeal .alt_ul{
	font-size: 14px;
    color: #333;
    background: #f5f5f5;
    border: 1px solid #dcdcdc;
    list-style: inside;
    margin-bottom: 20px;
    padding-bottom: 20px;
    margin-top:0;
}
.ccdeal .alt_ul li{
	list-style: inside;
    margin-top: 10px;
    margin-left: 10px;
}
/*.usercenter_all{width:100%;}*/
.ccdeal .usercernter_ul{
	display: flex;justify-content: space-between;

}
/*.el-button{padding:7px 15px;font-size: 12px;}*/
.ccdeal .el-table th{text-align: left;}
.ccdeal .el-table{border:1px solid #ebeef5;margin-top: 10px;}
.ccdeal .el-table thead tr th{background: #f5f5f5;}
.ccdeal .el-dialog__wrapper{
	display: flex;
	align-items: center;
}
.ccdeal .el-dialog{width:560px;}
.ccdeal .buysell .el-dialog{width:420px;}
.ccdeal .buysell .el-dialog__body{padding-bottom: 10px;padding-top: 5px;}
.ccdeal .buysell .el-button{padding:9px 15px;font-size: 12px;}
.ccdeal .buysell .remit_content{width: 100%;display: flex;}
.ccdeal .sellorder .el-dialog{width:430px;}
.ccdeal .sellorder.form_part .el-input{width:200px;}
.ccdeal .sellorder .verify .el-form-item__content{display: flex;align-items: center;}
.ccdeal .sellorder .verify .el-input{width: 119px;}
.ccdeal .sellorder .verify .el-input .el-input__inner{border-radius: 4px 0 0 4px;}
.ccdeal .sellorder .verify .el-button{height:36px;padding:7px 10px;font-size: 12px;border-radius:  0 4px 4px 0 ;background: #f5f7fa}
.ccdeal .sellorder  .btn_add .el-form-item__content{max-width: 200px;}
.ccdeal .dialog_alt{
	    margin-left: 130px;
    /*margin-top: 20px;*/
    /*margin-bottom: 5px;*/
    font-size: 12px;
    color: #f56c6c;
}
.ccdeal .form_part .el-input{width:324px;}
.ccdeal .form_part .el-input__inner{height:36px;}
.ccdeal .el-dialog__body{padding-top:0;}
.ccdeal .btn_add .el-form-item__content{max-width: 324px;}
.ccdeal .remit_content{width:340px;margin:0 auto;}
.ccdeal .remit_content ul{
	list-style: none;padding:0;
}
.ccdeal .remit_content ul li{
	display: flex;
}
.ccdeal .remit_content ul li .remit_label{width: 120px;}
.ccdeal .span_red{color:red;}
.ccdeal .note_input{width:50px;border:none;}
.ccdeal .span_btn_border{
	 height:24px;line-height: 24px;padding:0 5px;

}
</style>
<template>
  <div class="ccdeal">  
      
	<template v-if="routerPath=='ccdeal'" >

      <div class="login_content ccdeal">  
      		<div class="usercenter_all">
      			<div class="identity_header">      			
	      			<el-breadcrumb separator="/" class="bread" id="mybread">
				        <el-breadcrumb-item v-for="(item,index) in breadcrumbs" :key="index" :to="item">
				          {{ item.meta.name || item.name }}
				        </el-breadcrumb-item>
				      </el-breadcrumb>
	      		</div>
  				<div class="usercenter_header">      			
	      			<div class="header_left">
	      				<div class="header_img">
	      					<img src="../assets/img/bankcard.png">
	      					
	      				</div>
	      				<div class="header_text">
	      					<span>BTCX可用额度 0 BTCX</span>
      					  	
	      					<span >BTCX冻结额度 0 BTCX</span>
	      				</div>
	      			</div>
	      			<div class="header_right">
	      				<div class="header_btn" @click="addCard">
	      					<img src="../assets/img/add-bankcard.png">
	      					<p>添加您的银行卡</p>
	      				</div>
	      			</div>
	      		</div>
  			</div>   
      		
      		<div class="usercener_all">
      			<div class="usercenter_cc">
      				<div class="list_header">买入BTCX</div>
      				<div class="list_content">
  						<el-form  class="list_form"  :model="buyForm">
				            <el-form-item label="买入价(￥)" >
				               <el-input v-model="buyForm.buyprice" disabled  >
							  </el-input>
				            </el-form-item>
				          	 <el-form-item label="买入量(BTCX)" class="list_buynum">
				               <el-input v-model="buyForm.buynum" type="number" placeholder="请输入买入量" >
							  </el-input>
				            </el-form-item>
				            <span class="list_text">需要CNY:{{buyForm.buynum}}</span>
				            <el-form-item>
				            	<el-button style="width:100%;" class="span_btn_all" type="success" :loading="isBtnLoading"  @click="handlebuy()" >立即买入</el-button>
				            </el-form-item>

			          	</el-form>
      				</div>
      			</div>
      			<div class="usercenter_cc">
      				<div class="list_header">卖出BTCX</div>
      				<div class="list_content">
  						<el-form  class="list_form"  :model="sellForm">
				            <el-form-item label="卖出价(￥)" >
				               <el-input v-model="sellForm.sellprice" disabled  >
							  </el-input>
				            </el-form-item>
				          	 <el-form-item label="卖出量(BTCX)" class="list_buynum">
				               <el-input v-model="sellForm.sellnum" type="number" placeholder="请输入卖出量" >
							  </el-input>
				            </el-form-item>
				            <span class="list_text">需要BTCX:{{sellForm.sellnum}}</span>
				            <el-form-item>
				            	<el-button style="width:100%;" class="span_btn_all span_btn_red" type="success"  @click="handlesell()" >立即卖出</el-button>
				            </el-form-item>

			          	</el-form>
      				</div>
      			</div>
      		</div>
       		<div class="usercener_all">
       			<div class="alt_item">
       				<div class="alt_title">温馨提示</div>
	       			<div class="alt_content">
	       				<div class="alt_content_title">
	       					尊敬的hht.one用户：为了您的购买可以快速到账，请在交易前仔细阅读以下注意事项：
	       				</div>
	       				<ul class="alt_ul">
	       					<li>在平台发起充值申请后，请使用平台公布的汇款方式进行汇款</li>
	       					<li>商家处理时间9:00 - 21:00非处理时间的订单会在第二天9:00开始处理，接单后2小时内会完成交易，时间不会超过24小时。请在下单后30分钟内完成付款，否则会延时到账</li>
	       					<li>请使用本人绑定的银行卡通过手机银行或网银进行汇款，其他任何方式汇款都会造成延时处理</li>
	       					<li>如果你的交易24小时内没有处理，请联系在线客服登记。会有专人24小时内与您联系，请保持手机畅通</li>
	       					<li>由于咨询量过大，24小时内未处理的交易订单咨询，在线客服无法提供帮助。敬请谅解</li>
	       				</ul>
	       			</div>
       			</div>
       		</div>
       		<div class="usercenter_all">
       			<el-tabs v-model="activeName" >
					    <el-tab-pane  label="C2C买入记录" name="first">
					    	<el-table  :data="buylist"   style="width: 100%" :ref="buylist" >
							    <el-table-column   prop="idNo"  label="充值订单" >
							    </el-table-column>
							    <el-table-column   prop="createTime" label="充值时间">
							    </el-table-column>
							    <el-table-column   prop="type" label="充值方式" :formatter="formatType">
							    </el-table-column>
						        <el-table-column   prop="amount" label="充值金额">
						        	
							    </el-table-column>
						        <el-table-column   prop="amountReal" label="实际到账">
						        	
							    </el-table-column>
							  	 <el-table-column   prop="status" label="状态" :formatter="formatStatus">
						        	
							    </el-table-column>
							  
							    <el-table-column label="操作">
						            <template slot-scope="scope">					       
						              <span class="span_btn" v-if="scope.row.status==40"  @click="handleDeal(scope.$index, scope.row)" >撤单</span>				           
						             
						            </template>
					            </el-table-column>
						    </el-table>
						    <!--工具条-->
						    <el-col :span="24" class="toolbar toolbar_footer">			     
						      <el-pagination  layout="prev, pager, next,total,jumper" @current-change="handleCurrentChange" :page-size="showCount" :total="total" style="float:right;">
						      </el-pagination>
						    </el-col>
					    </el-tab-pane>
						<el-tab-pane  label="C2C卖出记录" name="second">
					    		<el-table  :data="sellist"   style="width: 100%" :ref="sellist" >
							    <el-table-column   prop="createTime"  label="提现时间" >
							    </el-table-column>
							    <el-table-column   prop="amount" label="提现金额">
							    </el-table-column>
							    <el-table-column   prop="fee" label="手续费">
							    </el-table-column>
						        <el-table-column   prop="amountReal" label="实际到账">
						        	
							    </el-table-column>
						        <el-table-column   prop="bankCard" label="银行卡号">
						        	
							    </el-table-column>
							  	 <el-table-column   prop="status" label="状态" :formatter="formatStatus">
						        	
							    </el-table-column>
							  
						    </el-table>
						    <!--工具条-->
						    <el-col :span="24" class="toolbar toolbar_footer">			     
						      <el-pagination  layout="prev, pager, next,total,jumper" @current-change="handleCurrentChange1" :page-size="showCount" :total="total1" style="float:right;">
						      </el-pagination>
						    </el-col>
					    </el-tab-pane>
						  
					</el-tabs>
					
       		</div>

      </div>
      	 <!-- 新增页面 -->
         <el-dialog title="添加银行卡" top="0"  class="form_part" :visible.sync="addFormVisible"  :close-on-click-modal="false">
	          <el-form :model="addForm" class="" label-width="130px" :rules="addFormRules" ref="addForm">
	            <!-- <div class="form_left"> -->
	            	<div class="dialog_alt">只可添加本人的银行卡</div>
	              <el-form-item label="开户名" prop="name">
	                <el-input v-model="addForm.name" disabled auto-complete="off"></el-input>
	              </el-form-item>
	              <el-form-item label="备注名" prop="remark">
	                <el-input v-model="addForm.remark" placeholder="请输入备注名" auto-complete="off"></el-input>
	              </el-form-item>  				               
	              <el-form-item label="开户银行" prop="bankName">
	                <el-select v-model="addForm.bankName" placeholder="请选择银行">
	                  <el-option label="中国银行" value="1"></el-option>
	                  <el-option label="建设银行" value="2"></el-option>
	                  <el-option label="工商银行" value="3"></el-option>
	                  <el-option label="农业银行" value="4"></el-option>
	                  <el-option label="交通银行" value="5"></el-option>
	                  <el-option label="民生银行" value="6"></el-option>
	                  <el-option label="招商银行" value="7"></el-option>
	                  <el-option label="广发银行" value="8"></el-option>
	                  <el-option label="浦发银行" value="9"></el-option>
	                </el-select>
	              </el-form-item>    
	              <el-form-item label="银行卡号" prop="bankCard">
	                <el-input v-model="addForm.bankCard" placeholder="填写正确的银行卡号，不必用空格隔开！" auto-complete="off"></el-input>
	              </el-form-item>     
	               <el-form-item label="重复卡号"  prop="reBankCard">
	                <el-input v-model="addForm.reBankCard" placeholder="请确认银行卡号" auto-complete="off"></el-input>
	              </el-form-item>  
	              <el-form-item label="交易密码:" prop="payPassword">
	                <el-input v-model="addForm.payPassword" placeholder="请输入交易密码" auto-complete="off"></el-input>
	              </el-form-item>
          		  <el-form-item class="btn_add">
	                 <el-button style="width:100%" type="primary"  @click.native="addSubmit('addForm')" :loading="addLoading">添加</el-button>
	              </el-form-item>
	           
	          </el-form>
	          <!-- <div slot="footer" class="dialog-footer">
	            <el-button style="width:100%" type="primary"  @click.native="addSubmit('addForm')" :loading="addLoading">添加</el-button>
	           
	          </div> -->
        </el-dialog>
        <!-- 卖出订单 -->
      	<el-dialog title="卖出订单" top="0"  class="form_part sellorder" :visible.sync="sellOrderVisible"  :close-on-click-modal="false">
	          <el-form :model="sellOrder" class="" label-width="100px" :rules="sellOrderRules" ref="sellOrder">
	            				               
	              <el-form-item label="选择银行" prop="userBankId">
	                <el-select v-model="sellOrder.userBankId" placeholder="请选择银行">
	                  <el-option v-for="item in userBanksList" :label="item.bankName" :value="item.userBankId" ></el-option>
	                  
	                </el-select>
	              </el-form-item>    
	                   
	              <el-form-item label="验证码" class="verify" prop="mobileCode">
		              <el-input type="text" placeholder="请输入验证码" class="phoneVerify" v-model="sellOrder.mobileCode"></el-input>
		              <el-button @click.native="sendVerify" type="default" class="verification1">获取验证码</el-button>

		          </el-form-item>
	              <el-form-item label="交易密码" prop="payPassword">
	                <el-input v-model="sellOrder.payPassword" placeholder="请输入交易密码" auto-complete="off"></el-input>
	              </el-form-item>
	              <el-form-item label="手续费率"  prop="iconResId">
	                <span class="el-tag el-tag--danger span_btn_border">1%</span>
	              </el-form-item> 
          		  <el-form-item class="btn_add">
	                 <el-button style="width:100%" type="primary"  @click.native="addSubmitSell('sellOrder')" :loading="sellOrderLoading">确定</el-button>
	              </el-form-item>
	           
	          </el-form>
	          <!-- <div slot="footer" class="dialog-footer">
	            <el-button style="width:100%" type="primary"  @click.native="addSubmit('addForm')" :loading="addLoading">添加</el-button>
	           
	          </div> -->
        </el-dialog>
         <!-- 汇款订单 -->
         <el-dialog title="汇款订单" top="0"  class="form_part" :visible.sync="remitFormVisible"  :close-on-click-modal="false">
	         <div class="remit_alt">请按提示信息向该卖家汇款</div>
	         <div class="remit_content">
	         	<ul>
	         		<li><span class="remit_label">收款方户名</span><span>杨梅</span></li>
	         		<li><span class="remit_label">收款方开户行</span><span>中国农业银行</span></li>
	         		<li><span class="remit_label">收款方账号</span><span>6230 5201 2002 5510 177</span></li>
	         		<li><span class="remit_label">转账金额</span><span class="span_red">{{remitData.amount}}元</span></li>
	         		<li><span class="remit_label">汇款时备注内容</span><span class="span_red">{{remitData.tradeNo}}(请务必填写)</span></li>
	         		<li><span class="remit_label">状态</span><span>{{remitData.statusName}}</span></li>

	         	</ul>
	         </div>
	          <div slot="footer" class="dialog-footer">
	            <el-button type="primary"  @click.native="remitFormVisible=false" :loading="addLoading">确定</el-button>
	           
	          </div>
        </el-dialog>
        <!-- 买入卖出提示 -->
         <el-dialog title="提示" top="0"  class="form_part buysell" :visible.sync="buySellVisible"  :close-on-click-modal="false">
	         <!-- <div class="remit_alt">请按提示信息向该卖家汇款</div> -->
	         <div class="remit_content">
	         	<i class="el-icon-success icon_success"></i>买入成功，请在30分钟内完成付款。
	         </div>
	          <div slot="footer" class="dialog-footer">
	            <el-button type="primary"  @click="buySellVisible=false;remitFormVisible=true" >确定</el-button>
	           
	          </div>
        </el-dialog>
    </template>
    <template v-else>
        <router-view></router-view>
    </template>
    
    
   
  </div>
</template>

<script>
import * as users from '../api/users';
import * as accountUser from '../api/accountUser';
import * as common from '../api/common';
import myHeader from './common/header'
import VueClipboard from 'vue-clipboard2'
import Vue from 'vue'

Vue.use(VueClipboard)



var code ; //在全局定义验证码
export default {

  components:{
    myHeader,VueClipboard
  },
  computed: {   
 	activeMenu: function(){
      // return this.$route.name
      return this.$route.path
    },
    breadcrumbs: function(){
      return (this.$route && this.$route.matched) || []
    }
  },
  data() {
    return {
    	sellOrderLoading:false,
    	tradeNo:'bj9w2',
    	addFormVisible:false,
    	remitFormVisible:false,
    	buySellVisible:false,
    	sellOrderVisible:false,
    	addForm:{name:''},
    	addFormRules:{
    		name:[
    			 { required: true, message: '必须是本人银行卡', trigger: 'blur' },
    		],
			remark:[
				 { required: true, message: '请输入备注名', trigger: 'blur' },
			],
			bankName:[
				 { required: true, message: '请选择开户银行', trigger: 'change' },
			],
			bankCard:[
				 { required: true, message: '请输入银行卡号', trigger: 'blur' },
			],
			reBankCard:[
				 { required: true, message: '再次输入银行卡号', trigger: 'blur' },
			],
			payPassword:[
				 { required: true, message: '请输入交易密码', trigger: 'blur' },
			],
    	},
    	userBanks:[
    		{name:'中国银行',userBankId:'1'},
    		{name:'建设银行',userBankId:'2'},
    		{name:'工商银行',userBankId:'3'},
    		{name:'农业银行',userBankId:'4'},
    		{name:'交通银行',userBankId:'5'},
    		{name:'民生银行',userBankId:'6'},
    		{name:'招商银行',userBankId:'7'},
    		{name:'广发银行',userBankId:'8'},
    		{name:'浦发银行',userBankId:'9'},
    	],
    	userBanksList:[],
    	sellOrder:{},
    	addLoading:false,
    	activeName:'first',
    	buylist:[],
    	sellist:[],
    	buyForm:{buyprice:1},   
    	sellForm:{sellprice:1},
    	isRecharge:true,
    	rechargeList:[],
    	withdrawList:[],
    	linkUrl:'复制内容',
    	expands:[],
    	filters:{},
    	userId:'',
    	list:[{name:'btc',cid:'1'},{name:'btc',cid:'2'}],
    	showCount:10,
		total:0,
		total1:0,
      	page: 1,
      	page1:1,
		onOff:true,
      	sellOrderRules:{
	        userBankId: [
	            { required: true, message: '请选择银行卡', trigger: 'change' },
	          ],
		    mobileCode: [
		        { required: true, message: '请输入验证码', trigger: 'blur' },
		    ],
		    payPassword: [
		        { required: true, message: '请输入交易密码', trigger: 'blur' },
		    ],
      },
      picLyanzhengma:'',
      checkCode:'',
      loginForm:{region:'china'},
      username: '',
      password: '',
      isBtnLoading: false,
      routerPath:'',
      isRealName:false,
      userInfo:'',
      showCount:20,
	  total:20,
	  page:1,
	  payType:4,
	  mobile:'',
	  verifycode:'1234',
	  isSendVerify:false,//是否发送了验证码
	  remitData:'',//汇款单信息
    };
  },
 
  methods: {
    sendVerify(){
      	if(this.mobile){
	        let para={
	          mobile:this.mobile,
	          verifyCode:this.verifycode
	        }
	        console.log(para)
	        common.sendVerify.r(para).then((res)=>{
	          console.log(res);
	          if(res.data.retCode==1){
	            this.isSendVerify=true;
	          }else{
	            this.$message(res.data.retMsg);
	          }
	        })
        }
     
    },
  	addSubmit(){
  		//添加银行卡
      	this.$refs.addForm.validate((valid) => {
	        if (valid) {
	    		if(this.addForm.bankCard!=this.addForm.reBankCard){
	            this.$message.error("两次输入银行卡号不一致");
	            return;
	      	}
	      	let bankNameBind='';
	      	this.userBanks.map(x=>{
	      		if(x.userBankId==this.addForm.bankName){
	      			bankNameBind=x.name
	      		}
	      	})
	      	console.log(bankNameBind);
	      	let para={
	      		bankName:bankNameBind,
	      		remark:this.addForm.remark,
	      		payPassword:this.addForm.payPassword,
	      		bankCard:this.addForm.bankCard,
	      		name:this.addForm.name,
	      		userId:this.userId,
	      	}
	      	console.log(para);
	      	// return;
	      	accountUser.bandCard.r(para).then((res)=>{
	      		console.log(res);
	      		if(res.data.retCode==1){
					this.addFormVisible=false;
					this.$message('银行卡绑定成功');
		  			
		  		}else{
		  			this.$message.error(res.data.retMsg);
		  		}
	      	})

	        }else{
	          console.log('error submit!!');
	          return false;
	        }

      	})

    },
    addSubmitSell(){
      this.$refs.sellOrder.validate((valid) => {
        if (valid) {
	    /*	if(!this.isSendVerify){
	            this.$message.error("请发送手机验证码");
	            return;
	      	}*/
	      	this.sellOrderLoading=true;
	      	let para={
	      		payPassword:this.sellOrder.payPassword,
	      		mobileCode:this.sellOrder.mobileCode,
	      		userBankId:this.sellOrder.userBankId,
	      		amount:this.sellForm.sellnum,
	      		userId:this.userId,
	      	}
	      	console.log(para);
	      	// return;
	      	accountUser.addwithdraw.r(para).then((res)=>{
	      		console.log(res);
	      		if(res.data.retCode==1){
					this.sellOrderVisible=false;
					this.$message("卖出订单申请成功，等待审核！");
					this.fetchDataSell();
		  			
		  		}else{
		  			this.$message.error(res.data.retMsg);
		  		}
		  		this.sellOrderLoading=false;
	      	})

        }else{
          console.log('error submit!!');
          return false;
        }

      })

    },
  	handlesell(){
		if(!this.sellForm.sellnum || this.sellForm.sellnum<100){
			this.$message.error("卖出金额必须大于100");
			return;
		}
  		this.sellOrderVisible=true;
  		this.fetchDataBrank();
  	},
  	addCard(){
  		this.addFormVisible=true;
  	},
  	handleCurrentChange(val) {
      this.page = val;
      // this.getUsers();
      this.fetchData();
    },
	handleCurrentChange1(val) {
      this.page1 = val;
      // this.getUsers();
      this.fetchDataSell();
    },
   	//状态转换
    formatType: function (row, column) {
      return row.type == 1 ? '银联支付' : row.type == 2 ? '支付宝支付' :row.type == 3 ? '微信支付' :row.type == 4 ? '线下支付' :'未知';
    },
    //状态显示转换
    formatStatus: function (row) {
      return row.status == 30 ? '待审核' : row.status == 31 ? '拒绝' :  row.status == 32 ? '完成' :  row.status == 40 ? '未付款' :  row.status == 41 ? '到账成功' :  row.status == 42 ? '人工到账' :  row.status == 43 ? '处理中' : '未知';
    },
	handlebuy:function(){
		//立即买入
		console.log(this.buyForm.buynum)
		if(!this.buyForm.buynum || this.buyForm.buynum<100){
			this.$message.error("充值金额必须大于100");
			return;
		}
		this.isBtnLoading=true;
		let para={
			userId:this.userId,
			amount:this.buyForm.buynum,
			payType:this.payType
		}
		console.log(para)
		accountUser.addrecharge.r(para).then((res)=>{
			console.log(res);
			if(res.data.retCode==1){
				this.buySellVisible=true;
				this.remitData=res.data.data;
				// this.tradeNo=res.data.data.tradeNo;
				this.remitData.statusName=this.formatStatus(this.remitData);
	  			
	  		}else{
	  			this.$message.error(res.data.retMsg);
	  		}
	  		this.isBtnLoading=false;
		})
	},
	
	onCopy: function (e) {//点击复制链接
		this.$message(this.linkUrl);
	},
	onError: function (e) {
        alert('网络错误')
  	},
  	getRowKeys(row) {
            return row.cid;
    },
  	toggleStatus(){
  		console.log(this.onOff)
  	},
 
    fetchDataUser(){
    	//获取用户信息
    	let para={
    		userId:this.userId,
    	}
	  	users.info.r(para).then((res) => {
	  		console.log(res)
	  		if(res.data.retCode==1){
	  			if(res.data.data.realName){
  					this.isRealName=true;
  				}else{
  					this.isRealName=false;
  				}
  				this.userInfo=res.data.data;
  				this.addForm.name=res.data.data.realName;
  				sessionStorage.setItem("localUser",JSON.stringify(res.data.data))
	  		}else{
	  			this.$message.error(res.data.retMsg);
	  		}
	       
	       

	      });
    },
    fetchDataBrank(){
    	//获取银行卡列表
    	let para={
    		userId:this.userId,
    	}
    	console.log(para)
	  	users.requestBank.r(para).then((res) => {
	  		console.log(res)
	  		if(res.data.retCode==1){
	  			this.userBanksList=res.data.data;
	  		}else{
	  			this.$message.error(res.data.retMsg);
	  		}
	       
	       

	      });
    },
 	fetchData(init) {
 		//获取c2c买入记录
      this.loading = true;
    /*  if(!this.$_has([users.request])){
        this.$message("暂无权限");
        this.loading = false;

        return;
      }*/
      let para = {
          // groupId:this.groupId,
          userId:this.userId,
          showCount:this.showCount,
          currentPage:this.page,//当前查询页
        };
 
      accountUser.request.r(para).then((res) => {
      	console.log(res);
      	if(res.data.retCode==1){
      		  this.total=parseInt(res.data.data.totalRow);
        	this.buylist = res.data.data.list;
      	}else{
      		this.$message.error(res.data.retMsg);
      	}
      
        
        this.loading = false;
      });
    },
 	fetchDataSell(init) {
 		//获取c2c卖出记录
      this.loading = true;
    
      let para = {
          // groupId:this.groupId,
          userId:this.userId,

          showCount:this.showCount,
          currentPage:this.page1,//当前查询页
        };
 
      accountUser.requestList.r(para).then((res) => {
      	console.log(res);
      	if(res.data.retCode==1){
      		  this.total1=parseInt(res.data.data.totalRow);
        	this.sellist = res.data.data.list;
      	}else{
      		this.$message.error(res.data.retMsg);
      	}
      
        
        this.loading = false;
      });
    },
  	handleRecharge(index,row){
  		console.log(this.expands.toString())
  		if(this.expands.toString()!=row.cid){
  			this.isRecharge=true;
	  		this.expands = [];
			this.expands.push(row.cid)
  		}else{
	  		this.expands = [];
  			
  		}
  		
  	},
	handleWithd(index,row){
		this.isRecharge=false;
		this.expands = [];
		this.expands.push(row.cid)
	},
	handleDeal(index,row){

	},

  },
	watch: {
      // 如果路由有变化，会再次执行该方法
      "$route": function(){
        this.routerPath=this.$route.path.split("/").pop();
        this.fetchDataUser()

      }
  },
  created() {
    this.routerPath=this.$route.path.split("/").pop();
    // sessionStorage.setItem('userId','152420221979644577')

  
    this.mobile=JSON.parse(sessionStorage.getItem('localUser')).mobile;
    this.userId=sessionStorage.getItem('userId')
      
    this.fetchDataUser();
    this.fetchData();
    this.fetchDataSell();
  }
};
</script>
